{% extends "templates/main_template.html.j2" %}


{% block title %}Проекты · Farado{% endblock %}

{% set active_menu = 'projects' %}


{#----------------------------------------------------------------------------#}
{% block styles %}
  <link href="/static/css/datatables.min.css" rel="stylesheet" type="text/css" />
  <link href="/static/css/dataTables.bootstrap5.min.css" rel="stylesheet" type="text/css" />
  <link href="/static/css/page-toolbar.css" rel="stylesheet" type="text/css" />
  <link href="/static/css/tables.css" rel="stylesheet" type="text/css" />
{% endblock %}


{#----------------------------------------------------------------------------#}
{% block breadcrumb %}
  <ol class="breadcrumb">
    <li class="breadcrumb-item active" aria-current="page">Проекты</li>
  </ol>
{% endblock %}


{#----------------------------------------------------------------------------#}
{% block content %}
  {% if restriction.is_create_enabled %}
    <div class="page-toolbar">
      <a href="/projects/add_project" class="btn btn-outline-primary btn-sm" role="button" aria-pressed="true"> <i
        class="bi bi-plus mr-1"></i> Добавить проект</a>
    </div>
  {% endif %}

  <div class="table-container">
    <table
        class="table table-striped table-sm table-bordered table-hover"
        style="width:100%"
        id="projects_table">
      <thead>
        <tr>
          <th scope="col" style="width: 2%">№</th>
          <th scope="col" style="width: 80%">Название</th>
          <th scope="col">Запросов</th>
          <th scope="col">Версий</th>
          <th scope="col">Изменение</th>
        </tr>
      </thead>
      <tbody>
        {% for project in project_manager.projects() %}
          <tr>
            <td>{{ project.id }}</td>
            <td>
              <a href="/projects/project/{{ project.id }}">{{ project.caption|e }}</a>
            </td>
            <td>
              {{- project_manager.raw_querier().project_issues_count(project.id) -}}
            </td>
            <td>
              {{- project_manager.raw_querier().project_versions_count(project.id) -}}
            </td>
            <td class="font-monospace text-nowrap">
              {{- project_manager.raw_querier().last_modified_project_date_time(project.id) -}}
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
{% endblock %}


{#----------------------------------------------------------------------------#}
{% block scripts %}
  <script src="/static/js/datatables.min.js"></script>
  <script src="/static/js/jquery.dataTables.min.js"></script>
  <script src="/static/js/dataTables.bootstrap5.min.js"></script>
  <script>
    document_ready_function = function() {
      $('#projects_table').DataTable({
          "paging": false,
          "fixedColumns": true,
          "processing": true,
          "serverSide": false,
          "ordering": true,
          "order": [[ 4, "desc" ]]
      });
    }
  </script>
{% endblock %}
